function [residual, g1, g2, g3] = model_static(y, x, params)
%
% Status : Computes static model for Dynare
%
% Inputs : 
%   y         [M_.endo_nbr by 1] double    vector of endogenous variables in declaration order
%   x         [M_.exo_nbr by 1] double     vector of exogenous variables in declaration order
%   params    [M_.param_nbr by 1] double   vector of parameter values in declaration order
%
% Outputs:
%   residual  [M_.endo_nbr by 1] double    vector of residuals of the static model equations 
%                                          in order of declaration of the equations.
%                                          Dynare may prepend or append auxiliary equations, see M_.aux_vars
%   g1        [M_.endo_nbr by M_.endo_nbr] double    Jacobian matrix of the static model equations;
%                                                       columns: variables in declaration order
%                                                       rows: equations in order of declaration
%   g2        [M_.endo_nbr by (M_.endo_nbr)^2] double   Hessian matrix of the static model equations;
%                                                       columns: variables in declaration order
%                                                       rows: equations in order of declaration
%   g3        [M_.endo_nbr by (M_.endo_nbr)^3] double   Third derivatives matrix of the static model equations;
%                                                       columns: variables in declaration order
%                                                       rows: equations in order of declaration
%
%
% Warning : this file is generated automatically by Dynare
%           from model file (.mod)

residual = zeros( 15, 1);

%
% Model equations
%

murkU__ = log(params(6)*((1-params(6))/y(5))^((1-params(6))/(params(6)+1/params(5))))+(1+params(5))/(1+params(6)*params(5))*params(11)*y(13)-(1-params(6))/(1+params(6)*params(5))*log(y(8));
sigrk_p__ = (1+params(5))/(1+params(6)*params(5))*params(12);
pi__ = 3.141592653589793;
ERkp1d__ = exp(murkU__+sigrk_p__^2/2)/2*(1+erf((y(12)-murkU__-sigrk_p__^2)/(sigrk_p__*1.414213562373095)))+y(4)*(1-params(7));
ERkp1u__ = exp(murkU__+sigrk_p__^2/2)*0.5*(1+erf((murkU__+sigrk_p__^2-y(12))/(sigrk_p__*1.414213562373095)))+(1-params(7))*(1-y(4));
T79 = y(15)^(1+1/params(5));
T101 = exp(y(13))*y(8)^params(6);
T102 = y(15)^(1-params(6));
T103 = T101*T102;
T117 = y(11)*(1-1/y(10));
T124 = params(7)+T117*(1+params(8)*(1-y(7)))-1;
T129 = params(8)*y(11)^2;
T130 = (1-y(7))*T129;
T133 = y(10)^2;
T134 = (y(10)-1)*(1+params(8)*(1-y(7)))*T130/T133;
T140 = T134/T124/(sigrk_p__*sqrt(2*pi__));
T145 = exp((-0.5)*((y(12)-murkU__)/sigrk_p__)^2);
lhs =y(4);
rhs =0.5*(1+erf((y(12)-murkU__)/(sigrk_p__*1.414213562373095)));
residual(1)= lhs-rhs;
lhs =1/(params(4)*y(11));
rhs =1+ERkp1d__*y(10)/(y(11)*(y(10)-1))-y(4)*params(8)-y(4);
residual(2)= lhs-rhs;
lhs =y(1);
rhs =T79*y(5)/(1-params(6));
residual(3)= lhs-rhs;
lhs =y(1);
rhs =T103;
residual(4)= lhs-rhs;
lhs =y(8);
rhs =y(8)*(1-params(7))+y(2);
residual(5)= lhs-rhs;
lhs =y(1);
rhs =y(14)+y(2);
residual(6)= lhs-rhs;
lhs =y(8);
rhs =y(10)*y(9);
residual(7)= lhs-rhs;
lhs =exp(y(12));
rhs =T124;
residual(8)= lhs-rhs;
lhs =(1-y(4))*y(11);
rhs =ERkp1u__-T140*T145;
residual(9)= lhs-rhs;
lhs =y(9);
rhs =params(10)*(y(9)+params(9)*(y(8)*(1+params(6)*y(1)/y(8)-params(7))-y(8)*T117-y(9)))+y(6)-x(2);
residual(10)= lhs-rhs;
lhs =y(13);
rhs =params(11)*y(13)+params(12)*x(1);
residual(11)= lhs-rhs;
lhs =y(3);
rhs =params(6)*y(1)/y(8)/exp(y(12));
residual(12)= lhs-rhs;
lhs =y(5);
rhs =(y(5));
residual(13)= lhs-rhs;
lhs =y(6);
rhs =(y(6));
residual(14)= lhs-rhs;
lhs =y(7);
rhs =(y(7));
residual(15)= lhs-rhs;
if ~isreal(residual)
  residual = real(residual)+imag(residual).^2;
end
if nargout >= 2,
  g1 = zeros(15, 15);

  %
  % Jacobian matrix
  %

T15 = (1-params(6))/(params(6)+1/params(5));
T24 = (1+params(5))/(1+params(6)*params(5))*params(11);
T37 = sigrk_p__^2;
T40 = exp(murkU__+T37/2);
T41 = T40/2;
T49 = 1+erf((y(12)-murkU__-T37)/(sigrk_p__*1.414213562373095));
T62 = 1+erf((murkU__+T37-y(12))/(sigrk_p__*1.414213562373095));
T202 = params(6)*(-(1-params(6)))/(y(5)*y(5))*getPowerDeriv((1-params(6))/y(5),T15,1)/(params(6)*((1-params(6))/y(5))^T15);
T209 = 2/(exp(((y(12)-murkU__)/(sigrk_p__*1.414213562373095))^2)*1.772453850905516);
T218 = 2/(1.772453850905516*exp(((y(12)-murkU__-T37)/(sigrk_p__*1.414213562373095))^2));
T234 = 2/(1.772453850905516*exp(((murkU__+T37-y(12))/(sigrk_p__*1.414213562373095))^2));
T240 = 2*(y(12)-murkU__)/sigrk_p__;
T265 = (1-params(6))/(1+params(6)*params(5))*1/y(8);
T398 = (-T24)/(sigrk_p__*1.414213562373095);
  g1(1,4)=1;
  g1(1,5)=(-(0.5*(-T202)/(sigrk_p__*1.414213562373095)*T209));
  g1(1,8)=(-(0.5*T209*T265/(sigrk_p__*1.414213562373095)));
  g1(1,12)=(-(0.5*T209*1/(sigrk_p__*1.414213562373095)));
  g1(1,13)=(-(0.5*T209*T398));
  g1(2,4)=(-((1-params(7))*y(10)/(y(11)*(y(10)-1))-params(8)-1));
  g1(2,5)=(-(y(10)*(T49*T40*T202/2+T41*(-T202)/(sigrk_p__*1.414213562373095)*T218)/(y(11)*(y(10)-1))));
  g1(2,8)=(-(y(10)*(T49*T40*(-T265)/2+T41*T218*T265/(sigrk_p__*1.414213562373095))/(y(11)*(y(10)-1))));
  g1(2,10)=(-((ERkp1d__*y(11)*(y(10)-1)-y(11)*ERkp1d__*y(10))/(y(11)*(y(10)-1)*y(11)*(y(10)-1))));
  g1(2,11)=(-params(4))/(params(4)*y(11)*params(4)*y(11))-(-(ERkp1d__*y(10)*(y(10)-1)))/(y(11)*(y(10)-1)*y(11)*(y(10)-1));
  g1(2,12)=(-(y(10)*T41*T218*1/(sigrk_p__*1.414213562373095)/(y(11)*(y(10)-1))));
  g1(2,13)=(-(y(10)*(T49*T24*T40/2+T41*T218*T398)/(y(11)*(y(10)-1))));
  g1(3,1)=1;
  g1(3,5)=(-(T79*1/(1-params(6))));
  g1(3,15)=(-(y(5)/(1-params(6))*getPowerDeriv(y(15),1+1/params(5),1)));
  g1(4,1)=1;
  g1(4,8)=(-(T102*exp(y(13))*getPowerDeriv(y(8),params(6),1)));
  g1(4,13)=(-T103);
  g1(4,15)=(-(T101*getPowerDeriv(y(15),1-params(6),1)));
  g1(5,2)=(-1);
  g1(5,8)=1-(1-params(7));
  g1(6,1)=1;
  g1(6,2)=(-1);
  g1(6,14)=(-1);
  g1(7,8)=1;
  g1(7,9)=(-y(10));
  g1(7,10)=(-y(9));
  g1(8,7)=(-(T117*(-params(8))));
  g1(8,10)=(-((1+params(8)*(1-y(7)))*y(11)*(-((-1)/(y(10)*y(10))))));
  g1(8,11)=(-((1-1/y(10))*(1+params(8)*(1-y(7)))));
  g1(8,12)=exp(y(12));
  g1(9,4)=(-y(11))-(-(1-params(7)));
  g1(9,5)=(-(T62*0.5*T40*T202+T40*0.5*T202/(sigrk_p__*1.414213562373095)*T234-T140*T145*(-0.5)*(-T202)/sigrk_p__*T240));
  g1(9,7)=T145*(T124*(y(10)-1)*(T130*(-params(8))+(1+params(8)*(1-y(7)))*(-T129))/T133-T134*T117*(-params(8)))/(T124*T124)/(sigrk_p__*sqrt(2*pi__));
  g1(9,8)=(-(T62*0.5*T40*(-T265)+T40*0.5*T234*(-T265)/(sigrk_p__*1.414213562373095)-T140*T145*(-0.5)*T240*T265/sigrk_p__));
  g1(9,10)=T145*(T124*((1+params(8)*(1-y(7)))*T130*T133-(y(10)-1)*(1+params(8)*(1-y(7)))*T130*2*y(10))/(T133*T133)-T134*(1+params(8)*(1-y(7)))*y(11)*(-((-1)/(y(10)*y(10)))))/(T124*T124)/(sigrk_p__*sqrt(2*pi__));
  g1(9,11)=1-y(4)-(-(T145*(T124*(y(10)-1)*(1+params(8)*(1-y(7)))*(1-y(7))*params(8)*2*y(11)/T133-T134*(1-1/y(10))*(1+params(8)*(1-y(7))))/(T124*T124)/(sigrk_p__*sqrt(2*pi__))));
  g1(9,12)=(-(T40*0.5*T234*(-1)/(sigrk_p__*1.414213562373095)-T140*T145*(-0.5)*T240*1/sigrk_p__));
  g1(9,13)=(-(T62*0.5*T24*T40+T40*0.5*T234*T24/(sigrk_p__*1.414213562373095)-T140*T145*(-0.5)*T240*(-T24)/sigrk_p__));
  g1(10,1)=(-(params(10)*params(9)*y(8)*params(6)/y(8)));
  g1(10,6)=(-1);
  g1(10,8)=(-(params(10)*params(9)*(1+params(6)*y(1)/y(8)-params(7)+y(8)*(-(params(6)*y(1)))/(y(8)*y(8))-T117)));
  g1(10,9)=1-params(10)*(1-params(9));
  g1(10,10)=(-(params(10)*params(9)*(-(y(8)*y(11)*(-((-1)/(y(10)*y(10))))))));
  g1(10,11)=(-(params(10)*params(9)*(-(y(8)*(1-1/y(10))))));
  g1(11,13)=1-params(11);
  g1(12,1)=(-(params(6)/y(8)/exp(y(12))));
  g1(12,3)=1;
  g1(12,8)=(-((-(params(6)*y(1)))/(y(8)*y(8))/exp(y(12))));
  g1(12,12)=(-((-(exp(y(12))*params(6)*y(1)/y(8)))/(exp(y(12))*exp(y(12)))));
  if ~isreal(g1)
    g1 = real(g1)+2*imag(g1);
  end
if nargout >= 3,
  %
  % Hessian matrix
  %

  g2 = sparse([],[],[],15,225);
if nargout >= 4,
  %
  % Third order derivatives
  %

  g3 = sparse([],[],[],15,3375);
end
end
end
end
